const redis = require("redis");

// 分割上下文
!(async function () {
  // const redisClient = redis.createClient(6379, '127.0.0.1')
  const redisClient = redis.createClient({
    url: "redis://127.0.0.1:6379",
  });

  // 连接
  await redisClient
    .connect()
    .then(() => console.log("redis connect success!"))
    .catch(console.error);

  // set
  await redisClient.set("money", "100000000");

  // get
  const cacheValue = await redisClient.get("money");
  console.log("_____", cacheValue);

  // 退出
  redisClient.quit();
})();
